package 第六周.homework;
//编写一个程序，计算并输出一组整数x1~xn的平均值和标准方差。假设输入不超过50个值。以浮点数计算均值和标准方差。假设输入
//不超过50个值。以浮点数计算均值（mean）和标准方差（sd）。
import java.util.Scanner;
public class pp8_5 {
    public static void main(String[] args) {
      int n;
      double sum = 0;
      int x;
      double sd2=0;
      Scanner scan = new Scanner(System.in);
      System.out.println("Please enter a length of x: ");
      n = scan.nextInt();


      int[] xteam = new int[n];
      for(int z=0;z<n;z++) {
          System.out.println("Please enter a number: ");
          x = scan.nextInt();
          xteam[z] = x;
      }
      for(int a =0; a<xteam.length;a++)
      {
          sum += xteam[a];
      }
      double mean;
      mean = sum/n;
      System.out.println("The average is :"+mean);
      for(int b =0 ;b<xteam.length;b++)
      {
          sd2 += Math.pow(xteam[b]-mean,2);
      }
      double sd = Math.sqrt(sd2);
      System.out.println("The sd is:"+sd);
    }
}
